package com.tiniplanet.webgate.service.impl;

import java.io.Serializable;
import java.util.List;

import com.tiniplanet.webgate.dao.BaseDao;
import com.tiniplanet.webgate.entity.AbstractModel;
import com.tiniplanet.webgate.service.BaseService;

public class BaseServiceImpl<T extends AbstractModel, Id extends Serializable>
		implements BaseService<T, Id> {

	BaseDao<T, Id> baseDao;

	public BaseServiceImpl(BaseDao<T, Id> baseDao) {
		this.baseDao = baseDao;
	}

	/**
	 * @param baseDao
	 *            the baseDao to set
	 */
	public void setBaseDao(BaseDao<T, Id> baseDao) {
		this.baseDao = baseDao;
	}

	@Override
	public T getById(Id id) {
		return baseDao.getById(id);
	}

	@Override
	public List<T> getAll() {
		return baseDao.getAll();
	}

	@Override
	public void save(T entity) {
		baseDao.save(entity);

	}

	@Override
	public void delete(T entity) {
		baseDao.delete(entity);

	}

	@Override
	public void deleteById(Id id) {
		baseDao.deleteById(id);

	}

	@Override
	public void add(T entity) {
		baseDao.add(entity);
	}

	@Override
	public long count() {
		return baseDao.count();
	}

}